#define _CRT_SECURE_NO_WARNINGS 1



#include<stdio.h>


int main()
{
	int n = 0, m = 0, i = 0, j = 0, arr[1001] = { 0 }, sum = 0, count = 0;
	scanf("%d %d", &n, &m);
	for (i = 0; i < n; i++)
	{
		arr[i] = i + 1;
	}
	for (i = 0; 1; i++)
	{
		if (arr[i] == 0)
			i = 0;
		sum++;
		if (sum == m)
		{
			printf("%d ", arr[i]);
			sum = 0;
			count++;
			if (count == n)
				break;
			for (j = i; j < n; j++)
			{
				arr[j] = arr[j + 1];
			}
			i--;
		}
	}
	
	return 0;
}